package com.zijin.exec;

import java.util.Scanner;

public class Text06 {
    public static void main(String[] args) {
        int money1 = 245;
        int money2 = 350;
        int money3 = 420;
        double totalAmount = 0;
        Scanner scanner = new Scanner(System.in);
        String choice = "";
        do {
            System.out.println("******************************");
            System.out.println("请选择购买的商品编号:");
            System.out.println("1.T恤 2.网球鞋 3.网球拍");
            System.out.println("******************************");
            System.out.print("请输入商品编号: ");
            int number1 = scanner.nextInt();
            System.out.print("请输入购买数量: ");
            int number2 = scanner.nextInt();
            switch (number1) {
                case 1:
                    System.out.println("T恤￥" + money1 + "\t数量" + number2 + "\t合计￥" + (money1 * number2));
                    totalAmount += money1 * number2;
                    break;
                case 2:
                    System.out.println("网球鞋￥" + money2 + "\t数量" + number2 + "\t合计￥" + (money2 * number2));
                    totalAmount += money2 * number2;
                    break;
                case 3:
                    System.out.println("网球拍￥" + money3 + "\t数量" + number2 + "\t合计￥" + (money3 * number2));
                    totalAmount += money3 * number2;
                    break;
                default:
                    System.out.println("商品编号无效");
            }
            System.out.print("是否继续(y/n): ");
            choice = scanner.next();
        } while (choice.equals("y"));
        System.out.println("\n购物总金额: " + totalAmount);
        double discount = 1.0;
        if (totalAmount >= 5000) {
            discount = 0.6;
        } else if (totalAmount >= 4000) {
            discount = 0.7;
        } else if (totalAmount >= 3000) {
            discount = 0.8;
        } else if (totalAmount >= 2000) {
            discount = 0.9;
        }
        double payable = totalAmount * discount;
        System.out.println("折扣: " + discount);
        System.out.println("应付金额: " + payable);
        System.out.print("请输入实付金额: ");
        double paid = scanner.nextDouble();
        double change = paid-payable;
        System.out.println("找钱: " + change);
    }
}
